package com.yunchao.bank.configure.data.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import com.yunchao.bank.configure.domain.model.ConfigureModel

@Entity(tableName = "configure")
internal data class ConfigureEntityModel(

    @PrimaryKey(autoGenerate = true)
    val id: Int = 0,

    // 网络配置
    val serverIp: String,
    val serverPort: String,
    val icCardIp: String,
    val icCardPort: String,
    val pdaDeviceIp: String,
    val pdaDevicePort: String,

    // 设备信息
    val personNumber: String,
    val deviceNumber: String,
    val deviceId: String,

    val singlePower: Int = 10,

    val loopPower: Int = 30,

    // 仓储编号
    val stackCode: String,

    val createTime: Long = System.currentTimeMillis()
)

internal fun ConfigureEntityModel.toDomainModel(): ConfigureModel = ConfigureModel(
    serverIp = serverIp,
    serverPort = serverPort,
    icCardIp = icCardIp,
    icCardPort = icCardPort,
    pdaDeviceIp = pdaDeviceIp,
    pdaDevicePort = pdaDevicePort,
    personNumber = personNumber,
    deviceNumber = deviceNumber,
    deviceId = deviceId,
    singlePower = singlePower,
    loopPower = loopPower,
    stackCode = stackCode
)